﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DTO;
using BUS;
using System.Collections.Generic;

namespace WebSieuThi.QuanLi.QuanLiHangAjax
{
    public partial class loaddshanghoa : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string str = "";
            string str1 = "<select id=\"Select2\" name=\"D1\" onchange=\"\">";

            

           str += "<table border=\"1\">"
   + "<tr><td>Mã</td><td>Tên hàng</td><td>Loại hàng</td><td>Đơn giá</td><td>Số lượng kho</td><td>Số lượng quầy</td><td>Delete</td></tr>";

           List<HangHoa> ls = new List<HangHoa>();
           ls = HangHoaBUS.LayDS();

           List<LoaiHangHoa> ll = new List<LoaiHangHoa>();
           ll = LoaiHangHoaBUS.LayDS();

           for (int i = 0; i < ll.Count; ++i)
           {
               str1 += "<option value=\"" + ll[i].Id + "\">" + ll[i].TenLoaiHang + "</option>";
           }


           for (int i = 0; i < ls.Count; ++i)
           {
           //    str1 += "<option value=\"" + ls[i].Id + "\">" + ls[i].TenHangHoa + "</option>"; ;
               str += "<tr><td>"+ls[i].MaHH+"</td><td>"+ls[i].TenHangHoa+"</td><td>"+ls[i].LoaiHangHoa.TenLoaiHang+"</td><td>"+ls[i].DonGia+"</td><td>"+ls[i].SoLuongTonKho+"</td><td>"+ls[i].SoLuongTaiQuay+"</td><td><input name=\""+ls[i].Id.ToString()+"\" type=\"button\" value=\"Delete\"  onclick=\"xoahang(this.name)\"/></td></tr>";
           }

            
           

           str += "<tr><td><input type=\"text\" name=\"txtmahang\" size=\"2\"/></td><td><input type=\"text\" name=\"txttenhang\" size=\"17\"/></td><td>";
           str += str1 + "</td><td><input type=\"text\" name=\"txtdongia\" size=\"2\"/></td><td><input type=\"text\" name=\"txttonkho\" size=\"5\"/>";
           str += "</td><td><input type=\"text\" name=\"txtquay\" size=\"5\"/></td><td>";
           str += "<input type=\"button\" value=\"Add\"  onclick=\"themhang()\"/></td></tr>";

           str += "</table>";

            Response.Write(str);
        }
    }
}
